package com.ericom.model;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

@Entity
@Table(name = "group_sale")
public class GroupSale extends BaseObject {
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@Override
	public String toString() {
		return new ToStringBuilder(this).append("id", id)
				.append("title", title).append("description", description)
				.append("valideFrom", valideFrom).append("valideTo", valideTo)
				.append("price", price).append("minQuntity", minQuntity)
				.append("supplier", supplier).append("product", product)
				.toString();
	}

	@Override
	public boolean equals(final Object other) {
		if (!(other instanceof GroupSale))
			return false;
		GroupSale castOther = (GroupSale) other;
		return new EqualsBuilder().append(id, castOther.id)
				.append(title, castOther.title).isEquals();
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(id).append(title).toHashCode();
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "valide_from")
	public String getValideFrom() {
		return valideFrom;
	}

	public void setValideFrom(String valideFrom) {
		this.valideFrom = valideFrom;
	}

	@Column(name = "valide_to")
	public String getValideTo() {
		return valideTo;
	}

	public void setValideTo(String valideTo) {
		this.valideTo = valideTo;
	}

	public float getPrice() {
		return price;
	}

	public void setPrice(float price) {
		this.price = price;
	}

	@Column(name = "min_quntity")
	public int getMinQuntity() {
		return minQuntity;
	}

	public void setMinQuntity(int minQuntity) {
		this.minQuntity = minQuntity;
	}
	@OneToOne(optional = false, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "supplier_id", unique = true)
	public Supplier getSupplier() {
		return supplier;
	}

	public void setSupplier(Supplier supplier) {
		this.supplier = supplier;
	}
	@OneToOne(optional = false, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "product_id", unique = true)
	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	private Long id;
	private String title;
	private String description;
	private String valideFrom;
	private String valideTo;
	private float price;
	private int minQuntity;
	private Supplier supplier;
	private Product product;
	private String status;

}
